<template>
  <div>文本查看器</div>
  <div>{{content}}</div>
</template>

<script>
import {getFile} from "@/api/file";

export default {
  name: "Text",
  data() {
    return {
      path: "",
      content:"",
    }
  },
  methods: {
    getPath() {
      this.path = this.getQueryString("path")
    },
    getQueryString(name) {
      let reg = `(^|&)${name}=([^&]*)(&|$)`
      let r = window.location.search.substr(1).match(reg);
      if (r != null) return unescape(r[2]);
      return null;
    },
    async showContent() {
      let res = await getFile({path: this.path})
      this.content=res.data
    }
  },
  mounted() {
    this.getPath()
    this.showContent()
  }
}
</script>

<style scoped>

</style>